package com.dutychain.handler.impl;

import com.dutychain.handler.Handler;
import com.dutychain.request.HttpRequest;

public class HeadCheckHandler extends Handler {
    @Override
    public void doFilter(HttpRequest request) {
        System.out.println("before filter HeadCheckHandler.");
        HttpRequest.Message message = request.getMessage();
        String header = message.getHeader();
        if ( header == null || "".equals(header) ) {
            System.out.println("error: header of message can't be empty.");
            return;
        }
        if ( getNext() != null )
            getNext().doFilter(request);
        System.out.println("after filter HeadCheckHandler.");
    }
}
